<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="">
    <meta name="author" content="">

    <link rel="shortcut icon" href="<!--{eval echo register_static('img/touch-icon-57x57.png');}-->">

    <title>粉粉管理系统</title>

    <!-- Bootstrap core CSS -->
    <link href="<!--{eval echo register_static('css/bootstrap.min.css');}-->" rel="stylesheet">
    <link href="<!--{eval echo register_static('css/bootstrap-reset.css');}-->" rel="stylesheet">

    <!--Animation css-->
    <link href="<!--{eval echo register_static('css/animate.css');}-->" rel="stylesheet">

    <!--Icon-fonts css-->
    <link href="<!--{eval echo register_static('assets/font-awesome/css/font-awesome.css');}-->" rel="stylesheet" />
    <link href="<!--{eval echo register_static('assets/ionicon/css/ionicons.min.css');}-->" rel="stylesheet" />

    <link href="<!--{eval echo register_static('assets/sweet-alert/sweet-alert.min.css');}-->" rel="stylesheet">
    <!-- Plugins css -->
    <link href="<!--{eval echo register_static('assets/modal-effect/css/component.css');}-->" rel="stylesheet">

    <!-- DataTables -->
    <link rel="stylesheet" href="<!--{eval echo register_static('assets/datatables/jquery.dataTables.min.css" rel="stylesheet');}-->" />

    <!-- Custom styles for this template -->
    <link href="<!--{eval echo register_static('css/style.css');}-->" rel="stylesheet">
    <link href="<!--{eval echo register_static('css/helper.css');}-->" rel="stylesheet">

    <!-- My styles for this template -->
    <link href="<!--{eval echo register_static('css/common.css');}-->" rel="stylesheet">

</head>

<body>

<!-- Aside Start-->
<!--{template admin_v2/leftside}-->
<!-- Aside Ends-->


<!--Main Content Start -->
<section class="content">

    <!-- Header -->
    <!--{template admin_v2/header}-->
    <!-- Header Ends -->


    <!-- Page Content Start -->
    <!-- ================== -->

    <div class="wraper container-fluid diarys">

        <div class="row">
            <div class="col-md-12">
                <div class="panel panel-default">
                    <div class="panel-heading">
                        <h3 class="panel-title">{$goods_name}商店</h3>
                    </div>
                    <div class="panel-body">
                        <div class="row" style="margin-bottom:5px">
                            <div class="col-md-5 col-sm-5 col-xs-5">
                                <button class="btn btn-info myAdd"><i class="ion-plus-round"></i> 添加</button>
                                <input type="hidden" name="goods_name" value="{$goods_name}"/>
                                <button class="btn btn-info" id="refresh_planner" data-type="{$goods}"><i class="ion-loop"></i> 刷新更新时间</button>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-md-12 col-sm-12 col-xs-12">
                                <table id="datatable" class="table table-striped table-bordered">
                                    <thead>
                                    <tr>
                                        <th style="width: 5%;">
                                            <div class="btn-group">
                                                <button type="button" class="btn btn-info dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                                                    批量操作 <span class="caret"></span>
                                                </button>
                                                <ul class="dropdown-menu">
                                                    <li><a href="#" class='batchAction layerLoad'  data-type='online'>资源上线</a></li>
                                                    <li><a href="#" class='batchAction layerLoad' data-type='offline'>资源下线</a></li>
                                                    <li><a href="#" class='batchAction layerLoad' data-type='common'>普通类型</a></li>
                                                    <li><a href="#" class='batchAction layerLoad' data-type='new'>new标签</a></li>
                                                    <li><a href="#" class='batchAction layerLoad' data-type='hot'>hot标签</a></li>
                                                    <li><a href="#" class='batchAction layerLoad' data-type='notag'>去除标签</a></li>
                                                    <li><a href="#" class='batchAction layerLoad' data-type='addlabel'>上推荐</a></li>
                                                    <li><a href="#" class='batchAction layerLoad' data-type='removelabel'>下推荐</a></li>
                                                </ul>
                                            </div>
                                        </th>
                                        <th>ID</th>
                                        <th>封面</th>
                                        <th>名称</th>
                                        <th>任务</th>
                                        <th>价格</th>
                                        <th>状态</th>
                                        <th>下载量</th>
                                        <th>上线时间</th>
                                        <!--{if $goods == 'Templets' || $goods == 'Bootmgrs'}-->
                                        <th>种类</th>
                                        <!--{/if}-->
                                        <th>类别</th>
                                        <th>推荐</th>
                                        <th>标签</th>
                                        <th>隐藏</th>
                                        <th>操作</th>
                                    </tr>
                                    </thead>
                                    <tbody>

                                    <!--{loop $list $value}-->
                                    <tr>
                                        <td>
                                            <label class="cr-styled">
                                                <input type="checkbox" class="batch" data-id="{$value[id]}">
                                                <i class="fa"></i>
                                            </label>
                                        </td>
                                        <td><!--{$value[id]}--></td>
                                        <td><img height="40px" width="40px" src="{$value[cover_s]}"/></td>
                                        <td><!--{$value[name]}--></td>
                                        <td>
                                            <!--{if $value[task][type]}-->
                                            <span class="label label-danger">
							                <!--{$taskTypeArr[$value[task][type]]}-->限制,
                                                <!--{$value[task][desc]}-->
							                </span>
                                            <!--{else}-->
                                            <span class="label label-success">无任务限制</span>
                                            <!--{/if}-->
                                        </td>
                                        <td>
                                            <!--{if $value[price_final] > 0}-->
                                            <span class="badge badge-important">{$value[price_final]}</span> 金币
                                            <!--{else}-->
                                            免费
                                            <!--{/if}-->
                                        </td>
                                        <td>
                                            <!--{if $value[status] == 0}-->
                                            <i class="ion-checkmark-round" style="color:lightsalmon"></i>
                                            <!--{else}-->
                                            <i class="ion-close-round"></i>
                                            <!--{/if}-->
                                        </td>
                                        <td><!--{$value['sale_amount']}--></td>
                                        <td><!--{date('Y/m/d H:i:s',$value['time'])}--></td>
                                        <!--{if $goods == 'Templets' || $goods == 'Bootmgrs'}-->
                                        <td>
                                            <!--{if $value[kind] == 1}-->
                                            记录(1)
                                            <!--{elseif $value[kind] == 2}-->
                                            图片(2)
                                            <!--{else}-->
                                            未设置($value[kind])
                                            <!--{/if}-->
                                        </td>
                                        <!--{/if}-->
                                        <td>
                                            <!--{$value[category]}-->
                                        </td>
                                        <td>
                                            <!--{if $value[label] == 1}-->
                                            <i class="ion-checkmark-round" style="color:lightsalmon"></i>
                                            <!--{else}-->
                                            <i class="ion-close-round"></i>
                                            <!--{/if}-->
                                        </td>
                                        <td>
                                            <!--{if !empty($value[tag])}-->
                                            <!--{$value[tag][0][bg]}-->
                                            <!--{else}-->
                                            无
                                            <!--{/if}-->
                                        </td>
                                        <td>
                                            <!--{if $value[hidden] == 1}-->
                                            <i class="ion-checkmark-round" style="color:lightsalmon"></i>
                                            <!--{else}-->
                                            <i class="ion-close-round"></i>
                                            <!--{/if}-->
                                        </td>
                                        <td data-id="{$value[id]}" data-op="getPlanner{$goods}Detail">
                                            <!--<a href="admin.php?ac=planner_class&op=getPlanner{$goods}Detail&id={$value[id]}" target="_blank" role="button" class="btn btn-success btn-middle" >编辑</a>-->
                                            <a href="javascript:void(0);" class="on-default edit-row btn btn-default btn-sm getplanneretail"  ><i class="fa fa-pencil"></i></a>
                                            <!--{if $goods != 'Templets' && $goods != 'Bootmgrs'}-->

                                            <span class="nav_right"><a href="javascript:void(0);"  style="height:29px;" class="btn btn-primary btn-middle packaging" data-sid="{$value[id]}" >打包</a>
                                                <!--{if empty($value[download_url])}-->
								                            未打包
                                                <!--{else}-->
								                            已打包
                                                <!--{/if}-->
                                            </span>
                                            <!--{/if}-->
                                            <span class="nav_right"><a href="admin.php?ac=planner_class&op=get{$goods}CountList&id={$value['id']}&name={$value['name']}" target="_blank" style="height:29px;" class="btn btn-primary btn-middle">查看下载量</a></span>
                                        </td>
                                        <div id="addPlanner{$value[id]}" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel_addPlanner{$goods}" aria-hidden="true">
                                            <div class="modal-header">
                                                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                                                <h3 id="myModalLabel_add{$goods}">添加{$goods_name}包</h3>
                                            </div>

                                            <form  class="form-inline" role="form" method="post" action='admin.php?ac=pack&op=submit' enctype="multipart/form-data">
                                                <div class="modal-body nav-category" style="max-height:800px;">
                                                    <div class="form-group">
                                                        <label>ID
                                                            <input type="text" class="form-control" name="id" placeholder="id" value={$value[id]} >
                                                        </label>
                                                    </div>
                                                    <div class="form-group">
                                                        <label>拼音名称
                                                            <input type="text" class="form-control" name="name" placeholder="请输入名称拼音">
                                                        </label>
                                                    </div>
                                                    <div class="form-group">
                                                        <label for="inputfile">选择包文件
                                                            <input type="file" id="inputfile" name="package">
                                                        </label>
                                                    </div>
                                                </div>
                                                <div class="modal-footer">
                                                    <input type="hidden" name="type" value="{$packtype}">
                                                    <input type="hidden" name="subtype" value="{$value['categoryNum']}">
                                                    <button type="submit" class="btn btn-default layerLoad" >提交</button>
                                                </div>
                                            </form>
                                        </div>

                                    </tr>
                                    <!--{/loop}-->

                                    </tbody>

                                </table>
                                <!--{if $pageUrl}-->
                                <ul class="pager">
                                    <li>
                                        <a href="{$pageUrl['prev']}">
                                            <i class="fa fa-angle-double-left"></i> 上一页
                                        </a>
                                    </li>
                                    <li>
                                        <a href="{$pageUrl['first']}">
                                            <i class="fa"></i> 第一页
                                        </a>
                                    </li>
                                    <li>
                                        <a href="{$pageUrl['next']}"> 下一页
                                            <i class="fa fa-angle-double-right"></i>
                                        </a>
                                    </li>
                                </ul>
                                <!--{/if}-->
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>

    </div>
    <!-- Page Content Ends -->
    <!-- ================== -->

    <div id="con-close-modal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style="display: none;">

    </div><!-- /.modal -->


    <!-- Footer Start -->
    <!--{template admin_v2/footer}-->
    <!-- Footer Ends -->

</section>
<!-- Main Content Ends -->

<script type="text/javascript" src="static_v2/js/jquery.js"></script>
<script type="text/javascript" src="static_v2/layer/layer.js"></script>
<script type="text/javascript" src="static_v2/laytpl/laytpl.js"></script>

<script type="text/template" id="addModal">
    <form>
        <div>
            <table class="table table-bordered">
                <tbody>
                <tr>
                    <td>id号</td>
                    <td>
                        <input class="form-control"  type="text" placeholder="id" name="idd">
                    </td>
                </tr>
                <tr>
                    <td>名称</td>
                    <td>
                        <input class="form-control"  type="text" placeholder="name" name="namet">
                    </td>
                </tr>
                <tr>
                    <td>介绍</td>
                    <td>
                        <textarea class="form-control" rows="3" placeholder="介绍" name="desc"></textarea>
                    </td>
                </tr>
                <tr>
                    <td>推荐</td>
                    <td>
                        <select style="height: 26px;width: 100px" name="label">
                            <option value="0">否</option>
                            <option value="1">是</option>
                        </select>
                    </td>
                </tr>
                <tr>
                    <td>标签</td>
                    <td>
                        <select style="height: 26px;width: 100px" name="tag">
                            <option value="new">最新</option>
                            <option value="hot">最热</option>
                            <option value="">无</option>
                        </select>
                    </td>
                </tr>
                <tr>
                    <td>类型</td>
                    <td>
                        <select style="height: 26px;width: 100px" name="category">
                            <option value="">无</option>
                            <!--{loop $categories $key=>$val}-->
                            <option value="{$key}">{$val}</option>
                            <!--{/loop}-->
                        </select>
                    </td>
                </tr>
                <tr>
                    <td>操作</td>
                    <td style="text-align: center">
                        <input type="hidden" name="op" value="addPlanner{$goods}"/>
                        <button type="button" class="btn btn-info myAddPost">添加</button>
                    </td>
                </tr>
                </tbody>
            </table>
        </div>
    </form>
</script>

<!-- js placed at the end of the document so the pages load faster -->
<script src="<!--{eval echo register_static('js/jquery.js');}-->"></script>
<script src="<!--{eval echo register_static('js/bootstrap.min.js');}-->"></script>
<script src="<!--{eval echo register_static('js/pace.min.js');}-->"></script>
<script src="<!--{eval echo register_static('js/wow.min.js');}-->"></script>
<script src="<!--{eval echo register_static('js/jquery.nicescroll.js');}-->" type="text/javascript"></script>
<script type="text/javascript" src="<!--{eval echo register_static('assets/spinner/spinner.min.js');}-->"></script>
<script src="<!--{eval echo register_static('js/jquery.app.js');}-->"></script>
<script src="<!--{eval echo register_static('assets/sweet-alert/sweet-alert.min.js');}-->"></script>
<script src="<!--{eval echo register_static('assets/sweet-alert/sweet-alert.init.js');}-->"></script>
<!--Handlebars-->
<script src="<!--{eval echo register_static('js/handlebars-v4.0.5.js');}-->"></script>
<script src="<!--{eval echo register_static('js/handlebars-helper.js');}-->"></script>

<script src="<!--{eval echo register_static('assets/modal-effect/js/classie.js');}-->"></script>
<script src="<!--{eval echo register_static('assets/modal-effect/js/modalEffects.js');}-->"></script>

<script  type="text/template" id="editsource">
    {{#.}}
    <div class="container">
        <form action="admin.php" method="get" id="editsourcedata">
            <div class="row">
                <div class="col-md-6">
                    <div class="form-group">
                        <label for="labelid" class="control-label">id号</label>
                        <input class="form-control" id="labelid" type="text"  placeholder="id" name="id" value="{{detail.id}}">
                    </div>
                </div>
                <div class="col-md-6">
                    <div class="form-group">
                        <label for="labelname" class="control-label">名称</label>
                        <input class="form-control" id="name" type="text" placeholder="name" name="name" value="{{detail.name}}" >
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-md-3">
                    <div class="form-group">
                        <label for="labeltag" class="control-label">分类</label>
                        <select name="status" class="form-control" id="status">
                            <option value="1" {{detail.status_css.[1]}}>下架</option>
                            <option value="0" {{detail.status_css.[0]}}>上架</option>
                        </select>
                    </div>
                </div>
                <div class="col-md-3">
                    <div class="form-group">
                        <label for="labeltag" class="control-label">标签</label>
                        <select name="tag" class="form-control" id="tag">
                            <option value="">无</option>
                            <option value="new" {{detail.tag_css.new}}>最新</option>
                            <option value="hot" {{detail.tag_css.hot}}>最热</option>
                        </select>
                    </div>
                </div>
                <div class="col-md-3">
                    <div class="form-group">
                        <label for="labelstatus" class="control-label">类型</label>
                        <select name="category" class="form-control" id="category">
                            <option value="">无</option>
                            <!--{loop $categories $key=>$val}-->
                            <option value="{$key}" {{detail.category_css.[$key]}}><!--{$val}--></option>
                            <!--{/loop}-->
                        </select>
                    </div>
                </div>
            </div>
                <div class="row">
                <div class="col-md-3">
                    <div class="form-group">
                        <label for="labelstatus" class="control-label">推荐</label>
                        <select name="label" class="form-control" id="label">
                            <option value="1" {{detail.label_css.[1]}}>推荐</option>
                            <option value="0" {{detail.label_css.[0]}}>无</option>
                        </select>
                    </div>
                </div>
                <div class="col-md-3">
                    <div class="form-group">
                        <label for="labelname_tag" class="control-label">类别</label>
                        <select name="name_tag" class="form-control" id="name_tag">
                            <option value="0" {{detail.name_tag_css.[0]}}>静图</option>
                            <option value="1" {{detail.name_tag_css.[1]}}>动图</option>
                        </select>
                    </div>
                </div>
                <div class="col-md-3">
                    <div class="form-group">
                        <label for="labelvip" class="control-label">V I P</label>
                        <select name="vip" class="form-control" id="vip">
                            <option value="0" {{detail.vip_css.[0]}}>普通</option>
                            <option value="1" {{detail.vip_css.[1]}}>VIP</option>
                        </select>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-md-6">
                    <div class="form-group">
                        <label for="labelexpire_time" class="control-label">下载</label>
                        <input class="form-control" id="sale_amount" type="text" placeholder="下载量" name="sale_amount" value="{{detail.sale_amount}}">
                    </div>
                </div>
                <div class="col-md-6">
                    <div class="form-group">
                        <label for="labelexpire_time" class="control-label">大小</label>
                        <input class="form-control" id="zip_size" type="text" placeholder="包大小" name="zip_size" value="{{detail.zip_size}}">
                    </div>
                </div>
                <div class="col-md-6">
                    <div class="form-group">
                        <label for="labelexpire_time" class="control-label">有效期</label>
                        <input class="form-control" id="expire_time" type="text" placeholder="有效期" name="expire_time" value="{{detail.expire_time}}">
                    </div>
                </div>
                <div class="col-md-6">
                    <div class="form-group">
                        <label for="labelprice_orign" class="control-label">原价</label>
                        <input class="form-control" id="price_orign"  type="text" placeholder="原价(粉币)" name="price_orign" value="{{detail.price_orign}}">
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-md-6">
                    <div class="form-group">
                        <label for="labelprice_final" class="control-label">促销价</label>
                        <input class="form-control" id="price_final"  type="text" placeholder="折扣/会员价(粉币)" name="price_final" value="{{detail.price_final}}" >
                    </div>
                </div>
                <div class="col-md-6">
                    <div class="form-group">
                        <label for="labeldesc" class="control-label">介绍</label>
                        <input class="form-control" id="desc" type="text" placeholder="介绍" name="desc" value="{{detail.desc}}">
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-md-6">
                    <div class="form-group">
                        <label for="labelcover" class="control-label">封面</label>
                        <input class="form-control" id="cover_s" type="text" placeholder="封面" name="cover_s" value="{{detail.cover_s}}">
                    </div>
                </div>
                <div class="col-md-6">
                    <div class="form-group">
                        <label for="labeluid" class="control-label">作者</label>
                        <input class="form-control" id="cuid"  type="text" placeholder="作者UID" name="cuid" value="{{detail.cuid}}">
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-md-6">
                    <div class="form-group">
                        <label for="labeldownload_url" class="control-label">在商店隐藏(1:隐藏,0:不隐藏)</label>
                        <input class="form-control" id="labelvip" type="text" placeholder="" name="vip" value="{{detail.vip}}">
                    </div>
                </div>
                <div class="col-md-6">
                    <div class="form-group">
                        <label for="labelthumbnail_m" class="control-label">(大于)最低版本号(ios|安卓|ios专业) 4.7.1|4.33|4.7.1</label>
                        <input class="form-control" id="versionsupport" type="text" placeholder="ios|android|proios" name="versionsupport" value="{{detail.versionsupport}}">
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-md-6">
                    <div class="form-group">
                        <label for="labeldownload_url" class="control-label">包地址</label>
                        <input class="form-control" id="download_url" type="text" placeholder="包地址" name="download_url" value="{{detail.download_url}}">
                    </div>
                </div>
                <div class="col-md-6">
                    <div class="form-group">
                        <label for="labelthumbnail_m" class="control-label">预览图</label>
                        <input class="form-control" id="labelthumbnail_m" type="text" placeholder="预览图" name="thumbnail_m" value="{{detail.thumbnail.m}}">
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-md-6">
                    <div class="form-group">
                        <label for="labelthumbnail_s" class="control-label">预览小图</label>
                        <input class="form-control" id="labelthumbnail_s" type="text" placeholder="预览小图" name="thumbnail_s" value="{{detail.thumbnail.s}}">
                    </div>
                </div>
                <div class="col-md-6">
                    <div class="form-group">
                        <!--<label for="labeltask" class="control-label">下载限制</label>-->
                        <!--<select name="task_type" class="form-control" id="option">-->
                            <!--<option value="0">无限制11</option>-->
                            <!--<option value="1"-->
                            <!--&lt;!&ndash;{if detail.task_type==1}&ndash;&gt;-->
                            <!--selected-->
                            <!--&lt;!&ndash;{/if}&ndash;&gt;-->
                            <!--&gt;等级</option>-->
                            <!--<option value="2"-->
                            <!--&lt;!&ndash;{if detail.task_type==2}&ndash;&gt;-->
                            <!--selected-->
                            <!--&lt;!&ndash;{/if}&ndash;&gt;-->
                            <!--&gt;达人</option>-->
                        <!--</select>-->
                        <!--<div class='well'>-->
                            <!--<select name="task_type" id="task_type">-->
                                <!--<option value=0>无限制</option>-->
                                <!--<option value=1-->
                                        <!--{if $detail['task_type']==1}-->
                                <!--selected-->
                                <!--{/if}-->
                                <!--&gt;等级</option>-->
                                <!--<option value=2-->
                                        <!--{if $detail['task_type']==2}-->
                                <!--selected-->
                                <!--{/if}-->
                                <!--&gt;达人</option>-->
                                <!--<option value=3-->
                                        <!--{if $detail['task_type']==3}-->
                                <!--selected-->
                                <!--{/if}-->
                                <!--&gt;粉币</option>-->
                                <!--<option value=4-->
                                        <!--{if $detail['task_type']==4}-->
                                <!--selected-->
                                <!--{/if}-->
                                <!--&gt;会员</option>-->
                            <!--</select>-->
                            <!--<span id="task_option">-->
									<!--{if $detail['task_type']==1}-->
										<!--等级数：<input type="text" name="task_num" value="$detail['task_num']">说明：<input type="text" name="task_msg" value="$detail['task_msg']">-->
									<!--{elseif $detail['task_type']==2}-->
										<!--达人：<input type="text" name="task_num" value="$detail['task_num']">说明：<input type="text" name="task_msg"  value="$detail['task_msg']">-->
									<!--{elseif $detail['task_type']==3}-->
										<!--粉币数：<input type="text" name="task_num" value="$detail['task_num']"> 说明：<input type="text" name="task_msg" value="$detail['task_msg']">-->
									<!--{elseif $detail['task_type']==4}-->
										<!--会员：<input type="text" name="task_num" value="$detail['task_num']"> 说明：<input type="text" name="task_msg" value="$detail['task_msg']">-->
									<!--{else}-->
										<!--无限制-->
									<!--{/if}-->
                            <!--</span>-->
                        <!--</div>-->

                        <label for="labelthumbnail_s" class="control-label">下载限制</label>
                        <br>
                            <select name="task_type" id="task_type" style="height:34px">
                                <option value="0">无限制</option>
                                <option value="1" {{detail.level.[1]}}>等级</option>
                                <option value="2" {{detail.level.[2]}}>达人</option>
                                <option value="3" {{detail.level.[3]}}>粉币</option>
                                <option value="4" {{detail.level.[4]}}>会员</option>
                            </select>
                    </div>
                </div>
            </div>

            <input type="hidden" name="ac" value="planner_class"/>
            <input type="hidden" name="op" value="editPlanner{{{goods}}}"/>
            <input type="hidden" name="id" value="{{{detail.id}}}"/>
            <button type="button" style="float:right" id="editsource" class="btn btn-primary">提交</button>
        </form>
    </div>
    {{/.}}
</script>

<script type="text/template" id="pack">
    {{#.}}
    <form   style="margin-left: 10px;"  role="form" method="post" action='admin.php?ac=pack&op=submit' enctype="multipart/form-data">
        <div class="form-group">
            <label for="ids">ID</label>
            <input type="text" id="ids" class="form-control" name="id" value={{this.id}} >
        </div>

        <div class="form-group">
            <label for="pinname">拼音名称</label>
            <input type="text"  id="pinname" class="form-control" name="name" placeholder="请输入名称拼音">
        </div>
        <div class="form-group">
            <label for="inputfile">选择包文件
            </label>
            <input type="file" id="inputfile" name="package">
        </div>
        <input type="hidden" name="type" value="{{this.packtype}}">
        <button type="submit" class="btn btn-info layerwait" >执行</button>
    </form>
    {{/.}}
</script>

<script type="text/javascript">
    //添加
    $(document).off('click','.myAdd').on('click','.myAdd', function () {
        var goods_name = $("input[name='goods_name']").val();
        layer.open({
            content:$('#addModal').html(),
            type: 1,
            title: '添加'+goods_name+'包',
            closeBtn: 1,
            area:['30%', '80%'],
            shadeClose: true
        })
    });
    //提交添加
    $(document).off('click','.myAddPost').on('click','.myAddPost', function () {
        var data = {};
        data['id']       = $("input[name='idd']").val();
        data['name']     = $("input[name='namet']").val();
        data['desc']     = $("textarea[name='desc']").val();
        data['label']    = $("select[name='label']").val();
        data['tag']      = $("select[name='tag']").val();
        data['category'] = $("select[name='category']").val();
        data['op']       = $("input[name='op']").val();
        $.ajax({
            dataType : 'json',
            url  : 'admin.php?ac=planner_class',
            type : 'GET',
            data : data,
            success: function(r){
                if(r == 1){
                    setTimeout(function(){
                        layer.msg('操作成功');
                        window.location.reload();
                    },1000);
                }
            }
        });
    });
    //刷新
    $(document).on('click','#refresh_planner',function () {
        var type = $(this).data('type');
        $.ajax({
            type:'GET',
            url:'admin.php?ac=planner_class&op=updatePlanner',
            data:{type:type},
            success:function (data) {
                if(data==1){
                    layer.msg(type+'更新成功!');
                }else{
                    layer.msg(type+'更新失败');
                }
            }
        });
    })

    //批量操作
    ids=[];
    $('.batch').click(function(){
        var id = $(this).data('id');
        var index = $.inArray(id,ids);
        if(index !== -1){
            ids.splice(index,1);
            $(this).attr('checked',false);
        }else{
            ids.push(id);
            $(this).attr('checked',true);
        }

    });
    $('.batchAction').click(function(){

        var actionType= $(this).data('type');

        if(typeof(actionType) == undefined){
            layer.msg('类型选择有误！');
            return false;
        }

        if(ids.length==0){
            layer.msg('请先勾选资源！');
            return false;
        }
        $.ajax({
            type:'GET',
            url:'planner_class.php',
            data:{'ids' : ids,'actionType':actionType,'editType':'editPlanner{$goods}','op':'setBatchData'},
            success:function(data){
                if(data==1){
                    layer.msg('操作成功!');
                }else{
                    layer.msg('操作失败!')
                }
                window.location.href="admin.php?ac=planner_class&op=getPlanner{$goods}List";

            }
        });
    });

    $(document).on('click','#editsource',function(){
        //编辑
        var data=$("#editsourcedata").serialize();
        layer.closeAll()
        swals(data);
    });

    //获取资源详情
    var tp_editsource = Handlebars.compile($('#editsource').html());
    $(".getplanneretail").click(function() {
        var planner = $(this).parent().data();
        var id   = planner.id;
        var op   = planner.op;
        var index= layer.load();
        $.ajax(
            {
                url     :   "admin.php",
                type    :   "GET",
                data    :   {'id' : id,'ac':'planner_class','op':op},
                success :   function(data)
                {
                    var html = tp_editsource(data);
                    layer.close(index);
                    layer.open({
                        type: 1,
                        title:'编辑'+data.goods_name,
                        skin: 'layui-layer-demo', //样式类名
                        closeBtn: 1, //显示关闭按钮
                        shift: 2,
                        area:['65%',"80%"],
                        shadeClose: true, //开启遮罩关闭
                        content: html
                    });
                }
            });
    });

    $(document).on('click','.layerwait',function () {
        var index = layer.load();
    })
    //打包
    $(document).off('.packaging').on('click','.packaging',function(){
        var id = parseInt($(this).data('sid'));

        if(id>10000 && id < 20000){
            var packType = '0';
        }else if(id >20000 && id < 30000){
            var packType = '1';
        }
        var data={'id':id,'packtype':packType};
        var packaging = Handlebars.compile($('#pack').html());
        layer.open({
            type: 1,
            title:'开始打包',
            skin: 'layui-layer-demo', //样式类名
            closeBtn: 1, //显示关闭按钮
            shift: 2,
            area:['400px',"300px"],
            shadeClose: true, //开启遮罩关闭
            content: packaging(data)
        });

    });
    //下载限制
    $(document).on('change','#task_type',function(){
        $("#task_option").html('');
        var id=$(this).val();
        if(id==0){
            $("#task_option").html('无限制');
        }
        if(id==1){
            $("#task_option").html('等级数：<input type="text" name="task_num" style="height:34px">说明：<input type="text" name="task_msg" style="height:34px">');
        }
        if(id==2){
            $("#task_option").html('达人：<input type="text" name="task_num" value="1" style="height:34px">说明：<input type="text" name="task_msg" value="达人专属" style="height:34px">');
        }
        if(id==3){
            $("#task_option").html('粉币数：<input type="text" name="task_num" style="height:34px"> 说明：<input type="text" name="task_msg" style="height:34px">');
        }
        if(id==4){
            $("#task_option").html('会员：<input type="text" name="task_num" value="0" style="height:34px">说明：<input type="text" name="task_msg" value="会员专属" style="height:34px">');
        }
    })

    var swals = function (data, url, title, text){
        if (url === undefined) {
            url = "admin.php?ac=planner_class";
        }
        if (title === undefined) {
            title = "确认操作?";
        }
        if (text === undefined) {
            text  = "请慎重操作!";
        }
                $.ajax(
                    {
                        dataType:   "json",
                        url     :   url,
                        type    :   "GET",
                        data    :   data,
                        success :   function(data)
                        {
                            if(data==1){
                                swal("操作完成!", "", "success");
                            }else{
                                swal("操作失败!", "", "error");
                            }
                            refresh();
                        }
                    })
    }

    // 刷新当前页面
    var refresh=  function (){
        setInterval(window.location.reload(),5000);
    }
</script>
</body>
</html>
